package bookdata.database;

import java.util.ArrayList;
import java.util.List;

import dao.impl.BookDaoImpl;
import dao.pojo.Book;
import file.tobookdata.FileToBookData;
import bookdata.tofile.BookdataToFile;

public class BookDataToDataBase {

	public void bookDataToDataBase() {
		FileToBookData ftbd = new FileToBookData();
		List<Book> bList=new ArrayList<Book>();
		BookDaoImpl bdi = new BookDaoImpl();
		Book[] b = new Book[10000];
		try {
			bList=ftbd.getBookDataFromFile("book.data");
		} catch (Exception e) {
			System.out.println("读文件出错...");
		}
		for (int i = 0; i < bList.size(); i++) {
			b[i] = new Book(bList.get(i).getId(), bList.get(i).getName(), bList
					.get(i).getPubDate(), bList.get(i).getAuthor(), bList
					.get(i).getPrice(), bList.get(i).isNew(), bList.get(i)
					.getPublisher());
			
			bdi.addBook(b[i]);
		}
		

	}
	

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		BookDataToDataBase bdtdb = new BookDataToDataBase();
		bdtdb.bookDataToDataBase();
		long end = System.currentTimeMillis();
		System.out.println(end - start);

	}
}
